<?php
	
	require_once "Data/Html.php";
	
	class MasterView extends Html
	{
		/* Member varaibles */
		private static $testButton = "testButton";
		private static $registerButton = "registerButton";
		private static $homeButton = "homeButton";
		private static $activeView = "";
		
		public function DoLoggedOutNavigationBar()
		{
			return Html::Div(
				"<form method='get' action=''>
					<ul id='navigationList'>
						<li>
							<input type='submit' value='Home' name='" .self::$homeButton . "' class='menuButton' />
						</li>
						<li>
							<input type='submit' value='Registration' name='" . self::$registerButton . "' class='menuButton' />
						</li>
						<li>
							<input type='submit' value='Test' name='" . self::$testButton . "' class='menuButton' />
						</li>
					</ul>
				</form>", "menuDiv");
		}
		
		public function DoLoggedInNavigationBar()
		{
			return Html::Div(
				"<form method='get' action=''>
					<ul id='navigationList'>
						<li>
							<input type='submit' value='Home' name='" .self::$homeButton . "' class='menuButton' />
						</li>
						<li>
							<input type='submit' value='Registration' name='" . self::$registerButton . "' class='menuButton' />
						</li>
						<li>
							<input type='submit' value='Test' name='" . self::$testButton . "' class='menuButton' />
						</li>
					</ul>
				</form>", "menuDiv");
		}
		
		private function TriedToViewTest() { return isset($_GET[self::$testButton]); }
		private function TriedToViewRegistration() { return isset($_GET[self::$registerButton]); }
		private function TriedToViewHome() { return isset($_GET[self::$homeButton]); }
		
		private function HaveActiveView()
		{
			if (!isset($_SESSION[self::$activeView]))
				return false;
		}
		
		public function IsViewingTest()
		{
			if (!isset($_SESSION[self::$activeView]))
				return false;
				
			return ($_SESSION[self::$activeView] == self::$testButton) ? true : false;
		}
		
		public function IsViewingRegistration()
		{
			if (!isset($_SESSION[self::$activeView]))
				return false;
			
			return ($_SESSION[self::$activeView] == self::$registerButton) ? true : false;
		}
		
		public function IsViewingHome()
		{
			if (!isset($_SESSION[self::$activeView]))
				return false;
				
			return ($_SESSION[self::$activeView] == self::$homeButton) ? true : false;
		}
		
		public function SetView()
		{
			if ($this->TriedToViewTest())
				$_SESSION[self::$activeView] = self::$testButton;
			
			if ($this->TriedToViewHome())
				$_SESSION[self::$activeView] = self::$homeButton;
			
			if ($this->TriedToViewRegistration())
				$_SESSION[self::$activeView] = self::$registerButton;
		}
		
		public function GetView()
		{
			return $_SESSION[self::$activeView];
		}
	}